﻿//**************************************************
function DoCallBack(functionName, functionArguments, endFunction, context){
    var vstateID = document.getElementById("__VIEWSTATEID");
    var vstateData;
    if(vstateID != null){
      vstateID = vstateID.value;
    }
    if(vstateID != null && vstateID.length > 0){
      vstateData = document.getElementById(vstateID);
    }
    if(vstateData != null){
      vstateData = vstateData.value;
    }
    if(vstateData == null){
      vstateData = "";
    }
    __theFormPostData = "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=&"  + vstateID + "=" + vstateData + "&";   
    
    WebForm_DoCallback('__Page', functionName + '|' + functionArguments, endFunction, context, callback_Error, false)        
}
//**************************************************
function callback_Error(message, context){
  alert(message)
}

var mFormData = null
//**************************************************
function DoFormCallBack(functionName, functionArguments, endFunction){
    
    mFormData = new String()
    InitFormCallback()
    
    __theFormPostData = "__FORMCALLBACK=1&__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=&" + mFormData
    WebForm_DoCallback('__Page', functionName + "|" + functionArguments, endFunction, null, null, false)        
}
//**************************************************
function InitFormCallback() {
    var count = theForm.elements.length;
    var element;
    for (var i = 0; i < count; i++) {
        element = theForm.elements[i];
        var tagName = element.tagName.toLowerCase();
        if (tagName == "input") {
            var type = element.type;
            
            if ((type == "text" || type == "hidden" || type == "password" || ((type == "checkbox" || type == "radio") && element.checked)) && (element.id != "__EVENTVALIDATION" && element.id != "__VIEWSTATE" && element.id != "__EVENTTARGET" && element.id != "__EVENTARGUMENT")) {
                
                InitCallbackAddField(element.name, element.value);
            }
        }
        else if (tagName == "select") {
            var selectCount = element.options.length;
            for (var j = 0; j < selectCount; j++) {
                var selectChild = element.options[j];
                if (selectChild.selected == true) {
                    InitCallbackAddField(element.name, element.value);
                }
            }
        }
        else if (tagName == "textarea") {
            InitCallbackAddField(element.name, element.value);
        }
    }
}
//**************************************************
function InitCallbackAddField(name, value) {
    mFormData += name + "=" + WebForm_EncodeCallback(value) + "&";
}
//**************************************************************************
function openWindow(url, windowHeight, windowWidth){		
	var windowLeft = (screen.availWidth / 2) - (windowWidth / 2);
	var windowTop = ((screen.availHeight / 2) - (windowHeight / 2)) - 20;
	var windowName = url.replace(/\W/g, "_")
	var newWindow = window.open(url, windowName, "height=" + windowHeight + ",width=" + windowWidth + ",status=yes, left=" + windowLeft + ", top=" + windowTop + ",scrollbars=yes");
	
	return newWindow
}
//**************************************************************************
function getElementsByNameEx(name){
  var output = null
  var collection = document.getElementsByName(name)
  
  if (collection.length !== 0){
    output = collection
  }else{
    output = new Array()
    output.push(collection)
  
  }
  
  return output;
}
//**************************************************************************